#include "Reader.h"

void readChar(FILE* is)
{
    char field[fieldWidth + 1];
    field[fieldWidth] = '\0';
    fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
}

void readChar(std::istream& is)
{
    is.rdbuf();
	char field[fieldWidth + 1];
    field[fieldWidth] = '\0';
    is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
}


void readString(FILE* is)
{
	 char field[fieldWidth + 1];
    field[fieldWidth] = '\0';
    fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
	fgets(field, fieldWidth + 1, is);
	fscanf(is, "%10*[\n]");              // Go to next line.
}

void readString(std::istream& is)
{
	char field[fieldWidth + 1];
    field[fieldWidth] = '\0';
    is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
	is.get(field, fieldWidth + 1);
	is.ignore(10, '\n');              // Go to next line.
}

void readChar(std::streambuf * is)
{
    
	char field[fieldWidth + 1];
    field[fieldWidth] = '\0';
    int count = 0;
    std::streamsize availableStreamSize = is->in_avail();
    std::streamsize getReturn = fieldWidth;
    while ( getReturn  <= availableStreamSize )
    {
        getReturn += is->sgetn(field, fieldWidth);
        count++;
        std::cout << "Line number " << count << " " <<"getReturn " << getReturn << " " << field << std::endl;
        is->pubseekoff(fieldWidth+1, std::ios_base::cur, std::ios_base::in | std::ios_base::out);
    }

}

void readString(std::streambuf  * is)
{
	char field[fieldWidth + 1];
    field[fieldWidth] = '\0';
    while (is->sgetn(field, fieldWidth + 1) != EOF)
    {

    }
}